package cn.elwy.kit.file.service;

import java.io.File;
import java.io.IOException;
import java.util.List;

import cn.elwy.common.util.PathUtil;
import cn.elwy.common.util.io.FileUtil;

public class ReadFilePathCopyFileToPath {

  public static void main(String[] args) {
    String resourcePath = PathUtil.getResourcePath(ReadFilePathCopyFileToPath.class, "/fileList.txt");
    ReadFilePathCopyFileToPath f = new ReadFilePathCopyFileToPath();
    f.readFilePathCopyToDest(resourcePath, "E:/temp/file");
    System.out.println(resourcePath);
  }

  public void readFilePathCopyToDest(String resourcePath, String destPath) {
    if (resourcePath != null) {
      try {
        List<String> fileList = FileUtil.readFileToList(resourcePath);
        if (fileList != null) {
          File destDir = new File(destPath);
          for (String string : fileList) {
            File srcFile = new File(string);
            FileUtil.copyFile(srcFile, destDir, srcFile.getName(), true);
          }
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
}
